//
//  JSMyGoodsCell.swift
//  fho
//
//  Created by 郭颢源 on 2021/4/21.
//

import UIKit

class JSMyGoodsCell: UITableViewCell {
    var imgView = UIImageView()
    var line = UIView()
    var content = UILabel()
    var timeLab = UILabel()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        //        content.preferredMaxLayoutWidth = 200
//        line.backgroundColor = .systemGray
//        timeLab.textColor = .systemGray2
//        content.textColor = .systemGray
//        imgView.image = UIImage(named: "arrTop")
//        imgView.backgroundColor = .white
//        imgView.layer.cornerRadius = 10
//        imgView.layer.masksToBounds = true
//        content.numberOfLines = 0
//        contentView.addSubview(line)
//        contentView.addSubview(imgView)
//        contentView.addSubview(content)
//        contentView.addSubview(timeLab)
//        imgView.snp.makeConstraints { (make) in
//            make.top.equalToSuperview().offset(10)
//            make.left.equalToSuperview().offset(20)
//            make.width.height.equalTo(20)
//        }
//        line.snp.makeConstraints { (make) in
//            make.top.bottom.equalToSuperview()
//            make.width.equalTo(1)
//            make.centerX.equalTo(imgView)
//        }
//        content.snp.makeConstraints { (make) in
//            make.left.equalToSuperview().offset(50)
//            make.right.equalToSuperview().offset(-20)
//            make.top.equalToSuperview().offset(5)
//            make.bottom.equalTo(timeLab.snp.top).offset(-5)
//        }
//        timeLab.snp.makeConstraints { (make) in
//            make.left.equalToSuperview().offset(50)
//            make.right.equalToSuperview().offset(-20)
//            make.height.equalTo(20)
//            make.bottom.equalToSuperview()
//        }
        //        contentView.showSubviews()
        setUI()
        contentView.showSubviews()
    }
    ///出发地
    let labStart = UILabel()
    ///到达地
    let labEnd = UILabel()
    ///货物状态
    let labState:UILabel = {
        var _lab = UILabel()
        
        return _lab
    }()
    
    ///发货人
    let lab1 = UILabel()
    ///发货电话
    let lab1Phone = UILabel()
    ///发货状态
    let lab1State = UILabel()
    ///收货人
    let lab2 = UILabel()
    ///收货电话
    let lab2Phone = UILabel()
    ///收货状态
    let lab2State = UILabel()
    ///件数
    let labNum = UILabel()
    ///合集
    let labTotal = UILabel()
    ///代收
    let labDs = UILabel()
    
    ///备注
    let labNote = UILabel()
    ///下单时间
    let labTime = UILabel()
    ///公司
    let labCom = UILabel()
    ///网点
    let labBra = UILabel()
    
    
    
    
    
    
    func setUI() {
        
        /// 底容器
        let container = UIView()
        contentView.addSubview(container)
        container.layer.cornerRadius = 5;
        container.layer.masksToBounds = true
        container.layer.shadowColor = UIColor.systemGray.cgColor
        container.layer.shadowOffset = CGSize(width: 3, height: 3)
        container.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5))
        }
        
        let container1 = UIView()
        container.addSubview(container1)
        container1.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview().offset(30)
            make.right.equalToSuperview().offset(-5)
            make.height.equalTo(90)
        }
        let line1 = UIView()
        container.addSubview(line1)
        line1.backgroundColor = .systemGray
        line1.snp.makeConstraints { (make) in
            make.top.equalTo(container1.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(1)
        }
        let container2 = UIView()
        container.addSubview(container2)
        container2.snp.makeConstraints { (make) in
            make.top.equalTo(line1.snp.bottom)
            make.left.equalToSuperview().offset(5)
            make.right.equalToSuperview().offset(-5)
            make.height.equalTo(30)
        }
        let line2 = UIView()
        container.addSubview(line2)
        line2.backgroundColor = .systemGray
        line2.snp.makeConstraints { (make) in
            make.top.equalTo(container2.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(1)
        }
        let container3 = UIView()
        container.addSubview(container3)
        container3.snp.makeConstraints { (make) in
            make.top.equalTo(line2.snp.bottom)
            make.left.equalToSuperview().offset(5)
            make.right.equalToSuperview().offset(-5)
            make.height.equalTo(120)
        }
        container1.addSubview(labStart)
        container1.addSubview(labEnd)
        container1.addSubview(labState)
        container1.addSubview(lab1)
        container1.addSubview(lab1Phone)
        container1.addSubview(lab1State)
        container1.addSubview(lab2)
        container1.addSubview(lab2Phone)
        container1.addSubview(lab2State)
        container1.subviews.snp.distributeSudokuViews(fixedLineSpacing: 2, fixedInteritemSpacing: 2, warpCount: 3)
        
        container2.addSubview(labNum)
        container2.addSubview(labTotal)
        container2.addSubview(labDs)
        container2.subviews.snp.distributeSudokuViews(fixedLineSpacing: 2, fixedInteritemSpacing: 2, warpCount: 3)
        ///备注
        let labNoteTitle = UILabel()
        labNoteTitle.text = "备注："
        ///下单
        let labTimeTitle = UILabel()
        labTimeTitle.text = "下单："
        ///公司
        let labComTitle = UILabel()
        labComTitle.text = "公司："
        ///网点
        let labBraTitle = UILabel()
        labBraTitle.text = "网点："
        
        container3.addSubview(labNoteTitle)
        container3.addSubview(labTimeTitle)
        container3.addSubview(labComTitle)
        container3.addSubview(labBraTitle)
        
        container3.addSubview(labNote)
        container3.addSubview(labTime)
        container3.addSubview(labCom)
        container3.addSubview(labBra)
        
        [labNoteTitle, labTimeTitle, labComTitle, labBraTitle].snp.distributeViewsAlong(axisType: .vertical, fixedSpacing: 0, leadSpacing: 0, tailSpacing: 0)
        [labNote, labTime, labCom, labBra].snp.distributeViewsAlong(axisType: .vertical, fixedSpacing: 0, leadSpacing: 0, tailSpacing: 0)
        [labNote, labTime, labCom, labBra].snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(55)
            make.right.equalToSuperview()
        }
        container.snp.makeConstraints { (make) in
            make.bottom.equalTo(container3)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
}
